package ${groupId}.${artifactIdProjectPackageName}.common.result;

import org.apache.commons.lang3.StringUtils;

/**
 * 错误代码类
 * @author lwd
 * @date 2021/1/14 10:19
 */

public abstract class ErrorCode implements SiteInfo {

    private String dcode;

    private int code;

    private String msg;

    protected static ErrorCode newInstance(String dcode,int code, String msg){
        return new DefaultErrorCode(dcode,code,msg);
    }

    public ErrorCode(String dcode,int code, String msg) {
        this.dcode = dcode;
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getDcode() {
        if(StringUtils.isBlank(getSiteName())){
            return dcode;
        }
        return getSiteName() + "_" + dcode;
    }

    public void setDcode(String dcode) {
        this.dcode = dcode;
    }

    @Override
    public abstract String getSiteName();



}
